# -*- coding:utf-8 -*-
import hashlib
from flask import request, escape

def get_md5(bytes):
    m = hashlib.md5()
    m.update(bytes)
    return m.hexdigest()


log_file = 'vsearch.log'

# 调用日志记录函数
def set_log(res):
    with open(log_file, 'a', encoding='utf-8') as f:
        print(request.form, request.remote_addr, request.user_agent, res, file=f, sep='|')

def get_log():
    with open(log_file, encoding='utf-8') as f:
        return [[escape(item) for item in line.split('|')] for line in f.read().split('\n')]